// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

int t, n;

const int N = 2600, M = 3, LIM = 200;

int sg[N][3];

int findsg(int a[3]) {
    for (int i=1; i<N; ++i) {
        for (int j=0; j<3; ++j) {
            map<int, int> mp;
            for (int k=0; k<3; ++k) {
                if (j == 0 || (j != k)) {
                    mp[sg[max(0, i-a[k])][k]] = 1;
                }
            }
            for (int k=0; ; ++k) {
                if (!mp.count(k)) {
                    sg[i][j] = k;
                    break;
                }
            }
        }
    }

    // for (int i=0; i<=20; ++i) {
    //     printf("%d: %d %d %d\n", i, sg[i][0], sg[i][1], sg[i][2]);
    // }

    for (int len=1; ; ++len) {
        bool ok = true;

        for (int j=LIM; j+len<N && ok; ++j) {
            for (int k=0; k<3; ++k) {
                if (sg[j][k] != sg[j+len][k]) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok)
            return len;
    }
    assert(0);

}

const int NN = 3e5+50;

LL b[NN];
int sgb[NN];

inline int getsg(LL i, int j, int T) {
    if (i < LIM)
        return sg[i][j];
    else {
        LL len = i - LIM;
        return sg[LIM + (len % T)][j];
    }
}

int main(int argc, char const *argv[]) {
    // code
    int t;
    scanf("%d", &t);
    for (int kk=0; kk<t; ++kk) {
        int a[3];
        scanf("%d%d%d%d", &n, &a[0], &a[1], &a[2]);
        int T = findsg(a);
        LL tsg = 0;
        for (int i=0; i<n; ++i) {
            scanf("%lld", &b[i]);
            sgb[i] = getsg(b[i], 0, T);
            tsg ^= sgb[i];
        }
        if (tsg == 0) {
            puts("0");
        } else {
            int ans = 0;
            for (int i=0; i<n; ++i) {
                for (int j=0; j<3; ++j) {
                    LL tmp = max(0LL, b[i] - a[j]);
                    if ((getsg(tmp, j, T) ^ sgb[i] ^ tsg) == 0)
                        ++ans;
                }
            }
            printf("%d\n", ans);
        }
        // dbg(T);
    }
    return 0;
}
